Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add ERC20FlashMint extension #407

Open
wants to merge 180 commits into
base: main
Choose a base branch
from

Conversation

Ifechukwudaniel
Copy link

@Ifechukwudaniel Ifechukwudaniel commented Nov 14, 2024

NOTE: It is impossible to write any unit tests until it is possible to mock contract::address() in tests (see OpenZeppelin/stylus-test-helpers#5).

Resolves #355

PR Checklist

  • Tests
  • Documentation
  • Changelog

Copy link

netlify bot commented Nov 14, 2024

Deploy Preview for contracts-stylus canceled.

Name Link
🔨 Latest commit a7c0160
🔍 Latest deploy log https://app.netlify.com/sites/contracts-stylus/deploys/67357c1f782e3e00081ecd3f

Copy link

netlify bot commented Nov 14, 2024

Deploy Preview for contracts-stylus canceled.

Name Link
🔨 Latest commit 6e535e6
🔍 Latest deploy log https://app.netlify.com/sites/contracts-stylus/deploys/677825c7715802000884216d

@Ifechukwudaniel
Copy link
Author

This is my initial draft

Copy link
Collaborator

@0xNeshi 0xNeshi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Ifechukwudaniel!
Thanks for the contribution!

The PR overall looks good, let's polish it a bit

contracts/src/flashloan/borrower.rs Outdated Show resolved Hide resolved
contracts/src/flashloan/borrower.rs Outdated Show resolved Hide resolved
contracts/src/token/erc20/extensions/flashmint.rs Outdated Show resolved Hide resolved
contracts/src/token/erc20/extensions/flashmint.rs Outdated Show resolved Hide resolved
contracts/src/token/erc20/extensions/flashmint.rs Outdated Show resolved Hide resolved
contracts/src/token/erc20/extensions/flashmint.rs Outdated Show resolved Hide resolved
contracts/src/token/erc20/extensions/flashmint.rs Outdated Show resolved Hide resolved
contracts/src/token/erc20/extensions/flashmint.rs Outdated Show resolved Hide resolved
contracts/src/token/erc20/extensions/flashmint.rs Outdated Show resolved Hide resolved
contracts/src/token/erc20/extensions/flashmint.rs Outdated Show resolved Hide resolved
@Ifechukwudaniel
Copy link
Author

@0xNeshi what do you think about the new implementation for the extension

@0xNeshi 0xNeshi requested review from bidzyyys and 0xNeshi December 30, 2024 10:33
Copy link
Collaborator

@bidzyyys bidzyyys left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost ready to merge.

contracts/src/token/erc20/utils/safe_erc20.rs Outdated Show resolved Hide resolved
docs/modules/ROOT/pages/erc20-flash-mint.adoc Outdated Show resolved Hide resolved
contracts/src/token/erc20/extensions/flash_mint.rs Outdated Show resolved Hide resolved
contracts/src/token/erc20/extensions/flash_mint.rs Outdated Show resolved Hide resolved
///
/// Returns a boolean value indicating whether the operation succeeded.
///
/// In order to have [`IErc3156FlashLender::flash_loan`] exposed in ABI, you
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section should be at the end of rust docs for the function.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's an existing thread related to this, see #407 (comment)

examples/erc20-flash-mint/tests/mock/borrower.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@bidzyyys bidzyyys left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would not include benchmarks as they do not cover everything. I suggest removing this part at all, wdyt @qalisander?

@bidzyyys bidzyyys self-requested a review January 3, 2025 12:16
Copy link
Collaborator

@bidzyyys bidzyyys left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comments.

contracts/src/utils/reentrant_call_handler.rs Show resolved Hide resolved
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If re-entrancy is not needed for this PR I would not include this change. Wdyt @qalisander @0xNeshi?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see if the reentrant feature is enabled in sdk, call gets unsafe

Copy link
Member

@qalisander qalisander left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job guys!
There few comments left to be resolved, overall LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature]: ERC20FlashMint extension
4 participants